<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>后台用户管理</title>
</head>
<link href="<?php echo $this->baseUrl;?>/admincss/style.css" rel="stylesheet" type="text/css" />
<script language="javascript" src="<?php echo $this->baseUrl;?>/adminjs/jquery.pack.js"></script>
<script language="javascript">
function doSubmit()
{
	var adminid = <?php echo $this->adminid;?>;
	var arr = [];
	$('input[type="checkbox"]:checked').each(function(){
		var mname = $(this).parent().prev().text();
		var name = this.value;
		arr.push(mname + '_' + name);
	});
	
	var url = "<?php echo $this->baseUrl;?>/index.php?m=admin&c=privilege&a=psave";
	$.post(url, {"id":adminid, "list[]":arr}, function (result){
		if (result == 'ok'){
			alert("保存成功!");
		}else{
			alert("保存失败"+result);
		}
	});
	
	return false;
}
</script>
<body>
<table class="tableA"  width="100%" border="1" class="tableA" >
  <tr align="center">
    <td nowrap="nowrap" width="80"><strong>模块</strong></td>
    <td nowrap="nowrap"><strong>功能<?php global $cfg;
     if (in_array($this->username, $cfg['masteradmin'])){echo '&nbsp;' . $this->username . "<font color='red'>具有所有的权限</font>";}?></strong></td>
  </tr>
<?php
$index = 0;
foreach ($this->menu as $mname => $modules){
$str = "";
foreach ($modules as $name => $v){
$index++;
$ischeck = (isset($this->pris[$mname]) && in_array($name, $this->pris[$mname]))?"checked=\"true\"" : "";
if (in_array($this->username, $cfg['masteradmin']))
	$ischeck = "checked=\"true\"";

	$str .= '<input id="cb_' . $index . '" type="checkbox" value="' . $name . '" ' . $ischeck . '/><label for="cb_' . $index . '">' . $name . "</label>&nbsp;&nbsp;";
}
print <<<EOT
  <tr>
    <td nowrap="nowrap">{$mname}</td>
    <td>{$str}</td>
  </tr>
EOT;
}
?>
  <tr>
    <td nowrap="nowrap" colspan="2">
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <input class="btn_submit"   type="submit" name="Submit2" value="保存" onclick='javascript:return doSubmit();'/>
    <input class="btn_std"  type="button" name="Submit22" value="返回" onclick='javascript:history.back(-1);'/></td>
  </tr>
</table>
</body>
</html>
